
/**
 * AppleIIGo
 * Mouse Interface Card class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "DigiSector65.h"

DigiSector65::DigiSector65(Motherboard * motherboard,
						   char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void DigiSector65::onMemoryRequested() {
	romMemoryOffset =
		motherboard->getMemory()->requestMemory(DIGISECTOR65_ROM_BYTENUM);
}

void DigiSector65::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Micro Works DigiSector-65 ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
											  DIGISECTOR65_ROM_BYTENUM,
											  romImage);
}

void DigiSector65::onResetAsserted(bool isRestart) {
	if (!isRestart)
		return;
	
	romBankOffset = 0x300;
}

void DigiSector65::writeIo(UINT16 address, UINT8 value) {
}

UINT8 DigiSector65::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 DigiSector65::readMemory(UINT16 address) {
	if (address & 0x800)
		return timingGenerator->readFloatingBus();
	else
		return romMemory[romBankOffset + (address & 0xff)];
}
